<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>BabyOS: b_modbus.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="2.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">BabyOS
   &#160;<span id="projectnumber">V1.1.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_b9223522bb56aee4ab59f7ba381d2163.html">bos</a></li><li class="navelem"><a class="el" href="dir_f2a2cc749b6bfcea90db6730434b0bd6.html">core</a></li><li class="navelem"><a class="el" href="dir_37b66dfbfdffce01c33ebea49c49c2c3.html">inc</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">b_modbus.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="b__modbus_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="preprocessor">#ifndef __B_MODBUS_H__</span></div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="preprocessor">#define __B_MODBUS_H__</span></div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;<span class="preprocessor">#ifdef __cplusplus</span></div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160; <span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;<span class="comment">/*Includes ----------------------------------------------*/</span></div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="b__config_8h.html">b_config.h</a>&quot;</span></div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;<span class="preprocessor">#if _MODBUS_ENABLE</span></div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;<span class="preprocessor">#pragma pack(1)</span></div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160; </div><div class="line"><a name="l00059"></a><span class="lineno"><a class="line" href="structb_m_b___r_t_u_s___w__t.html">   59</a></span>&#160;<span class="keyword">typedef</span> <span class="keyword">struct</span></div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;{</div><div class="line"><a name="l00061"></a><span class="lineno"><a class="line" href="structb_m_b___r_t_u_s___w__t.html#af5105c72a61e60d3b44670de20e0c3fb">   61</a></span>&#160;    uint8_t <a class="code" href="structb_m_b___r_t_u_s___w__t.html#af5105c72a61e60d3b44670de20e0c3fb">addr</a>;</div><div class="line"><a name="l00062"></a><span class="lineno"><a class="line" href="structb_m_b___r_t_u_s___w__t.html#ac6b64f60b8100dc86a10a524158c21ce">   62</a></span>&#160;    uint8_t <a class="code" href="structb_m_b___r_t_u_s___w__t.html#ac6b64f60b8100dc86a10a524158c21ce">func</a>;</div><div class="line"><a name="l00063"></a><span class="lineno"><a class="line" href="structb_m_b___r_t_u_s___w__t.html#a11760f5020019f4aa8cb02e694f7cc44">   63</a></span>&#160;    uint16_t <a class="code" href="structb_m_b___r_t_u_s___w__t.html#a11760f5020019f4aa8cb02e694f7cc44">reg</a>;       <span class="comment">//Big endian</span></div><div class="line"><a name="l00064"></a><span class="lineno"><a class="line" href="structb_m_b___r_t_u_s___w__t.html#a8bf0d44a6ead3e7cc2898ba02498749e">   64</a></span>&#160;    uint16_t <a class="code" href="structb_m_b___r_t_u_s___w__t.html#a8bf0d44a6ead3e7cc2898ba02498749e">num</a>;       <span class="comment">//Big endian</span></div><div class="line"><a name="l00065"></a><span class="lineno"><a class="line" href="structb_m_b___r_t_u_s___w__t.html#aa60093a9a5d5d17864cfda66c47733e3">   65</a></span>&#160;    uint16_t <a class="code" href="structb_m_b___r_t_u_s___w__t.html#aa60093a9a5d5d17864cfda66c47733e3">crc</a>;       <span class="comment">//Little endian</span></div><div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;}<a class="code" href="structb_m_b___r_t_u_s___w__t.html">bMB_RTUS_W_t</a>;</div><div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;</div><div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;</div><div class="line"><a name="l00069"></a><span class="lineno"><a class="line" href="structb_m_b___r_t_u_s___ack__t.html">   69</a></span>&#160;<span class="keyword">typedef</span> <span class="keyword">struct</span></div><div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;{</div><div class="line"><a name="l00071"></a><span class="lineno"><a class="line" href="structb_m_b___r_t_u_s___ack__t.html#af5105c72a61e60d3b44670de20e0c3fb">   71</a></span>&#160;    uint8_t <a class="code" href="structb_m_b___r_t_u_s___ack__t.html#af5105c72a61e60d3b44670de20e0c3fb">addr</a>;</div><div class="line"><a name="l00072"></a><span class="lineno"><a class="line" href="structb_m_b___r_t_u_s___ack__t.html#ac6b64f60b8100dc86a10a524158c21ce">   72</a></span>&#160;    uint8_t <a class="code" href="structb_m_b___r_t_u_s___ack__t.html#ac6b64f60b8100dc86a10a524158c21ce">func</a>;</div><div class="line"><a name="l00073"></a><span class="lineno"><a class="line" href="structb_m_b___r_t_u_s___ack__t.html#a5723e60ffd628510c699eddbce90be23">   73</a></span>&#160;    uint8_t <a class="code" href="structb_m_b___r_t_u_s___ack__t.html#a5723e60ffd628510c699eddbce90be23">len</a>;</div><div class="line"><a name="l00074"></a><span class="lineno"><a class="line" href="structb_m_b___r_t_u_s___ack__t.html#ad8b5a87c8c7c60e3c795c91b0549f05b">   74</a></span>&#160;    uint8_t buf[1];</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;}<a class="code" href="structb_m_b___r_t_u_s___ack__t.html">bMB_RTUS_Ack_t</a>;</div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;</div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;</div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;<span class="preprocessor">#pragma pack()</span></div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160; </div><div class="line"><a name="l00081"></a><span class="lineno"><a class="line" href="structb_m_b___info__t.html">   81</a></span>&#160;<span class="keyword">typedef</span> <span class="keyword">struct </span></div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;{</div><div class="line"><a name="l00083"></a><span class="lineno"><a class="line" href="structb_m_b___info__t.html#a858e2685fb0034acadcd8d48cf6f02b2">   83</a></span>&#160;    uint8_t <a class="code" href="structb_m_b___info__t.html#a858e2685fb0034acadcd8d48cf6f02b2">dev_no</a>;</div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;}<a class="code" href="structb_m_b___info__t.html">bMB_Info_t</a>;</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;   </div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;<span class="preprocessor">#ifndef NULL</span></div><div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;<span class="preprocessor">#define NULL ((void *)0)   </span></div><div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;</div><div class="line"><a name="l00106"></a><span class="lineno"><a class="line" href="group___m_o_d_b_u_s___exported___macros.html#ga390c9dfff738dfbd93ec65a676ec76e5">  106</a></span>&#160;<span class="preprocessor">#define L2B_B2L_16b(n)  (((n) &lt;&lt; 8) | (n &gt;&gt; 8))   </span></div><div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;</div><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;<span class="keywordtype">int</span> <a class="code" href="group___m_o_d_b_u_s___exported___functions.html#ga75fd562c121d4610608a1ab4053408da">bMB_Regist</a>(uint8_t dev_no);</div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;<span class="keywordtype">int</span> <a class="code" href="group___m_o_d_b_u_s___exported___functions.html#gaec54fcf815442f741b8b3f008ea67239">bMB_WriteCmd</a>(<span class="keywordtype">int</span> no, uint8_t addr, uint8_t func, uint16_t reg, uint16_t num);</div><div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;<span class="keywordtype">int</span> <a class="code" href="group___m_o_d_b_u_s___exported___functions.html#ga9e0e2e9b8286a5db0ff6ef63885b8b2e">bMB_CheckRTUS_ACK</a>(uint8_t *psrc, uint16_t len);</div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;</div><div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;<span class="preprocessor">#ifdef __cplusplus</span></div><div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;    }</div><div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;</div><div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;<span class="preprocessor">#endif  </span></div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;</div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;<span class="comment">/************************ Copyright (c) 2019 Bean *****END OF FILE****/</span></div><div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;</div><div class="ttc" id="structb_m_b___r_t_u_s___w__t_html_a8bf0d44a6ead3e7cc2898ba02498749e"><div class="ttname"><a href="structb_m_b___r_t_u_s___w__t.html#a8bf0d44a6ead3e7cc2898ba02498749e">bMB_RTUS_W_t::num</a></div><div class="ttdeci">uint16_t num</div><div class="ttdef"><b>Definition:</b> <a href="b__modbus_8h_source.html#l00064">b_modbus.h:64</a></div></div>
<div class="ttc" id="structb_m_b___r_t_u_s___w__t_html_a11760f5020019f4aa8cb02e694f7cc44"><div class="ttname"><a href="structb_m_b___r_t_u_s___w__t.html#a11760f5020019f4aa8cb02e694f7cc44">bMB_RTUS_W_t::reg</a></div><div class="ttdeci">uint16_t reg</div><div class="ttdef"><b>Definition:</b> <a href="b__modbus_8h_source.html#l00063">b_modbus.h:63</a></div></div>
<div class="ttc" id="structb_m_b___r_t_u_s___ack__t_html_af5105c72a61e60d3b44670de20e0c3fb"><div class="ttname"><a href="structb_m_b___r_t_u_s___ack__t.html#af5105c72a61e60d3b44670de20e0c3fb">bMB_RTUS_Ack_t::addr</a></div><div class="ttdeci">uint8_t addr</div><div class="ttdef"><b>Definition:</b> <a href="b__modbus_8h_source.html#l00071">b_modbus.h:71</a></div></div>
<div class="ttc" id="structb_m_b___r_t_u_s___w__t_html"><div class="ttname"><a href="structb_m_b___r_t_u_s___w__t.html">bMB_RTUS_W_t</a></div><div class="ttdef"><b>Definition:</b> <a href="b__modbus_8h_source.html#l00059">b_modbus.h:59</a></div></div>
<div class="ttc" id="structb_m_b___info__t_html_a858e2685fb0034acadcd8d48cf6f02b2"><div class="ttname"><a href="structb_m_b___info__t.html#a858e2685fb0034acadcd8d48cf6f02b2">bMB_Info_t::dev_no</a></div><div class="ttdeci">uint8_t dev_no</div><div class="ttdef"><b>Definition:</b> <a href="b__modbus_8h_source.html#l00083">b_modbus.h:83</a></div></div>
<div class="ttc" id="group___m_o_d_b_u_s___exported___functions_html_ga75fd562c121d4610608a1ab4053408da"><div class="ttname"><a href="group___m_o_d_b_u_s___exported___functions.html#ga75fd562c121d4610608a1ab4053408da">bMB_Regist</a></div><div class="ttdeci">int bMB_Regist(uint8_t dev_no)</div></div>
<div class="ttc" id="structb_m_b___r_t_u_s___w__t_html_ac6b64f60b8100dc86a10a524158c21ce"><div class="ttname"><a href="structb_m_b___r_t_u_s___w__t.html#ac6b64f60b8100dc86a10a524158c21ce">bMB_RTUS_W_t::func</a></div><div class="ttdeci">uint8_t func</div><div class="ttdef"><b>Definition:</b> <a href="b__modbus_8h_source.html#l00062">b_modbus.h:62</a></div></div>
<div class="ttc" id="structb_m_b___r_t_u_s___ack__t_html"><div class="ttname"><a href="structb_m_b___r_t_u_s___ack__t.html">bMB_RTUS_Ack_t</a></div><div class="ttdef"><b>Definition:</b> <a href="b__modbus_8h_source.html#l00069">b_modbus.h:69</a></div></div>
<div class="ttc" id="b__config_8h_html"><div class="ttname"><a href="b__config_8h.html">b_config.h</a></div></div>
<div class="ttc" id="structb_m_b___info__t_html"><div class="ttname"><a href="structb_m_b___info__t.html">bMB_Info_t</a></div><div class="ttdef"><b>Definition:</b> <a href="b__modbus_8h_source.html#l00081">b_modbus.h:81</a></div></div>
<div class="ttc" id="structb_m_b___r_t_u_s___ack__t_html_ac6b64f60b8100dc86a10a524158c21ce"><div class="ttname"><a href="structb_m_b___r_t_u_s___ack__t.html#ac6b64f60b8100dc86a10a524158c21ce">bMB_RTUS_Ack_t::func</a></div><div class="ttdeci">uint8_t func</div><div class="ttdef"><b>Definition:</b> <a href="b__modbus_8h_source.html#l00072">b_modbus.h:72</a></div></div>
<div class="ttc" id="group___m_o_d_b_u_s___exported___functions_html_ga9e0e2e9b8286a5db0ff6ef63885b8b2e"><div class="ttname"><a href="group___m_o_d_b_u_s___exported___functions.html#ga9e0e2e9b8286a5db0ff6ef63885b8b2e">bMB_CheckRTUS_ACK</a></div><div class="ttdeci">int bMB_CheckRTUS_ACK(uint8_t *psrc, uint16_t len)</div></div>
<div class="ttc" id="structb_m_b___r_t_u_s___w__t_html_af5105c72a61e60d3b44670de20e0c3fb"><div class="ttname"><a href="structb_m_b___r_t_u_s___w__t.html#af5105c72a61e60d3b44670de20e0c3fb">bMB_RTUS_W_t::addr</a></div><div class="ttdeci">uint8_t addr</div><div class="ttdef"><b>Definition:</b> <a href="b__modbus_8h_source.html#l00061">b_modbus.h:61</a></div></div>
<div class="ttc" id="group___m_o_d_b_u_s___exported___functions_html_gaec54fcf815442f741b8b3f008ea67239"><div class="ttname"><a href="group___m_o_d_b_u_s___exported___functions.html#gaec54fcf815442f741b8b3f008ea67239">bMB_WriteCmd</a></div><div class="ttdeci">int bMB_WriteCmd(int no, uint8_t addr, uint8_t func, uint16_t reg, uint16_t num)</div></div>
<div class="ttc" id="structb_m_b___r_t_u_s___ack__t_html_a5723e60ffd628510c699eddbce90be23"><div class="ttname"><a href="structb_m_b___r_t_u_s___ack__t.html#a5723e60ffd628510c699eddbce90be23">bMB_RTUS_Ack_t::len</a></div><div class="ttdeci">uint8_t len</div><div class="ttdef"><b>Definition:</b> <a href="b__modbus_8h_source.html#l00073">b_modbus.h:73</a></div></div>
<div class="ttc" id="structb_m_b___r_t_u_s___w__t_html_aa60093a9a5d5d17864cfda66c47733e3"><div class="ttname"><a href="structb_m_b___r_t_u_s___w__t.html#aa60093a9a5d5d17864cfda66c47733e3">bMB_RTUS_W_t::crc</a></div><div class="ttdeci">uint16_t crc</div><div class="ttdef"><b>Definition:</b> <a href="b__modbus_8h_source.html#l00065">b_modbus.h:65</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.14
</small></address>
</body>
</html>
